package com.anpxd.erpad.net

import com.anpxd.erpad.App
import com.anpxd.erpad.bean.*
import com.gg.baseproject.Response
import com.gg.net.ApiFactory
import io.reactivex.Observable
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.POST

/**
 * Creator : GG
 * Date    : 2018/1/19
 * Mail    : gg.jin.yu@gmai.com
 * Explain :
 */
interface ErpApi {

    /**
     * 登录
     */
    @FormUrlEncoded
    @POST("controller/Login")
    fun login(@Field("accountName") accountName: String,
              @Field("accountPassword") accountPassword: String,
              @Field("applicationId") applicationId: String = "171220110147618",
              @Field("loginUrl") loginUrl: String = "/controller/LoginJson",
              @Field("exceptionUrl") exceptionUrl: String = "/controller/LoginJson",
              @Field("logoutUrl") logoutUrl: String = "/controller/LoginJson"
    ): Observable<Response<User>>

    /**
     * 查询车辆列表
     */
    @FormUrlEncoded
    @POST("controller/getCarList")
    fun carList(@Field("pageIndex") pageIndex: Int,
                @Field("pageSize") pageSize: Int = 15,
                @Field("marketId") marketId: String? = App.instance.getUser()?.marketId,
                @Field("shopId") shopId: String? = App.instance.getUser()?.shopId,
                @Field("carOutColor") carOutColor: String? = null,
                @Field("modelId") modelId: Int? = null,
                @Field("seriesId") seriesId: Int? = null,
                @Field("brandId") brandId: Int? = null,
                @Field("carBargainPriceState") carBargainPriceState: Int? = null,
                @Field("carAuthState") carAuthState: Int? = null,
                @Field("carDetectState") carDetectState: Int? = null,
                @Field("carStockState") carStockState: Int? = null,
                @Field("carSaleState") carSaleState: Int? = 20,
                @Field("carOrderState") carOrderState: Int? = null,
                @Field("fromRetailPrice") fromRetailPrice: Double? = null,
                @Field("toRetailPrice") toRetailPrice: Double? = null,
                @Field("fromCarAge") fromCarAge: Int? = null,
                @Field("toCarAge") toCarAge: Int? = null,
                @Field("fromCreateTime") fromCreateTime: Int? = null,
                @Field("toCreateTime") toCreateTime: Int? = null,
                @Field("fromMileage") fromMileage: Int? = null,
                @Field("toMileage") toMileage: Int? = null,
                @Field("orderColunm") orderColunm: String? = null,
                @Field("orderMode") orderMode: String? = null,
                @Field("carCreateTime") carCreateTime: String? = null,
                @Field("carTitle") carTitle: String? = null
    ): Observable<Response<List<Car>>>


    /**
     * 获取品牌列表
     */
    @GET("controller/getGroupBrand")
    fun brand(): Observable<Response<ArrayList<BrandInfo>>>

    /**
     * 获取车系列表
     */
    @FormUrlEncoded
    @POST("controller/getSeriesList")
    fun series(@Field("brandId") brandId: Int?): Observable<Response<ArrayList<Series>>>


    /**
     * 获取店铺列表
     */
    @FormUrlEncoded
    @POST("controller/getShopList")
    fun shopList(@Field("marketId") marketId: String = App.instance.getUser()?.marketId
            ?: "", @Field("shopId") shopId: String = App.instance.getUser()?.shopId
            ?: ""): Observable<Response<ArrayList<Shop>>>
}

interface WxApi {


    @FormUrlEncoded
    @POST("controller/account/selectWxQrCode")
    fun getIcon(@Field("marketId") marketId: String? = App.instance.getUser()?.marketId):Observable<Response<WxQrCode>>
}